package CTRLayer;

import DBLayer.DBPartOrder;
import ModelLayer.PartOrder;
import ModelLayer.Product;

public class PartOrderCTR 
{
	private DBPartOrder dbPartOrder;
	private ProductCTR productCTR;
	
	public PartOrderCTR()
	{
		productCTR = new ProductCTR();
		dbPartOrder = new DBPartOrder();
	}	
	
	public void addPartOrder(String productEAN, int amount, int orderNO)
	{
		Product product = productCTR.getProduct(productEAN);
		PartOrder partOrder = new PartOrder(product, amount);
		//getOrder(Integer.toString(orderNO), true).addPartOrder(partOrder); //Er der nogen grund til dette?
		dbPartOrder.insertPartOrder(partOrder, Integer.toString(orderNO));
	}
	
	public void deletePartOrder(String orderNO, String productEAN)
	{
		dbPartOrder.removePartOrder(orderNO, productEAN);
	}
	
	public void removeAssociatedPartOrders(String orderNO)
	{
		dbPartOrder.removeAssociatedPartOrders(orderNO);
	}
}
